<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册 - 记账助手</title>
    <link rel="stylesheet" href="styles.css">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
    <div class="screen">
        
        <div class="app-container">
            <div class="auth-container">
                <div class="auth-logo">💰</div>
                <h1 class="auth-title">注册记账助手</h1>
                
                <form class="auth-form" id="register-form">
                    <div class="form-group">
                        <label class="form-label" for="username">用户名</label>
                        <input type="text" id="username" class="form-input" placeholder="请设置用户名" required>
                    </div>
                    
                    <div class="form-group">
                        <label class="form-label" for="password">密码</label>
                        <input type="password" id="password" class="form-input" placeholder="请设置密码" required>
                    </div>
                    
                    <div class="form-group">
                        <label class="form-label" for="confirm-password">确认密码</label>
                        <input type="password" id="confirm-password" class="form-input" placeholder="请再次输入密码" required>
                    </div>
                    
                    <button type="submit" class="btn btn-primary">注册</button>
                </form>
                
                <div class="auth-footer">
                    已有账号？<a href="login.html" class="auth-link">立即登录</a>
                </div>
            </div>
        </div>
    </div>

    <script>
        // 更新当前时间
        function updateTime() {
            const now = new Date();
            let hours = now.getHours();
            let minutes = now.getMinutes();
            hours = hours < 10 ? '0' + hours : hours;
            minutes = minutes < 10 ? '0' + minutes : minutes;
            document.getElementById('current-time').textContent = `${hours}:${minutes}`;
        }
        
        // 初始化时间并每分钟更新
        updateTime();
        setInterval(updateTime, 60000);
        
        // 注册表单提交
        document.getElementById('register-form').addEventListener('submit', function(e) {
            e.preventDefault();
            const username = document.getElementById('username').value;
            const password = document.getElementById('password').value;
            const confirmPassword = document.getElementById('confirm-password').value;
            
            // 验证密码是否一致
            if (password !== confirmPassword) {
                showAlert('两次输入的密码不一致，请重新输入');
                return;
            }
            
            // 这里应该是实际的注册逻辑，现在只是模拟
            if (username && password) {
                // 模拟注册成功
                showAlert('注册成功！即将跳转到登录页面...');
                setTimeout(() => {
                    window.location.href = 'login.html';
                }, 1500);
            } else {
                showAlert('请填写完整的注册信息');
            }
        });
        
        // Bootstrap 模态框函数
        function showAlert(message) {
            document.getElementById('alertModalBody').textContent = message;
            const alertModal = new bootstrap.Modal(document.getElementById('alertModal'));
            alertModal.show();
        }
    </script>

    <!-- Bootstrap 模态框 -->
    <div class="modal fade" id="alertModal" tabindex="-1" aria-labelledby="alertModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="alertModalLabel">提示</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body" id="alertModalBody">
                    <!-- 动态内容 -->
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" data-bs-dismiss="modal">确定</button>
                </div>
            </div>
        </div>
    </div>
</body>
</html>